import http from './http'

export default {
  getSession () {
    return http.get(`fd/session`)
  },

  getOssConfig (id) {
    return http.get(`aliyun/oss`)
  },

  requestCodeSms (phone) {
    let data = http.buildQuery({ phone })
    return http.post(`api/code/sms?_format=json`, data)
  },

  validateCode (data) {
    return http.post(`api/code/validate?_format=json`, http.buildQuery(data))
  },

  searchMail (mail) {
    let data = http.buildQuery({ mail })
    return http.post(`api/mail/search`, data)
  },

  searchApp (data) {
    let q = http.buildQuery(data)
    return http.get(`api/app/search?${q}`)
  },

  createApp (data) {
    return http.post(`api/app/create?_format=json`, data)
  },

  upgrade (data) {
    return http.post(`fd/app/purchase?_format=json`, http.buildQuery(data))
  }
}
